package com.zzh.tools.listener;

import android.view.View;
import android.widget.Toast;


import com.zzh.tools.ToolClickDelayedUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangzhihao
 * @email 506284835@qq.com
 * @date 2020-06-29
 * @desc
 */
public class ToolOnClickListener implements View.OnClickListener {

    public int id;
    private final List<Integer> mIgnoreFastViewId = new ArrayList<>();

    @Override
    public void onClick(View v) {
        id = v.getId();
        if (isFast() && !mIgnoreFastViewId.contains(id) && ToolClickDelayedUtils.isFastClick()) {
            id = -1;
            return;
        }
    }

    //是否处理连点
    public boolean isFast() {
        return true;
    }


    public ToolOnClickListener addIgnoreFastViewId(int viewId) {
        mIgnoreFastViewId.add(viewId);
        return this;
    }

}
